from django.db import models
# Create your models here.
class StockBasic(models.Model):
    ts_code = models.CharField(max_length=20)
    symbol = models.CharField(max_length=20)
    name = models.CharField(max_length=20)
    area = models.CharField(max_length=20)
    industry = models.CharField(max_length=20)
    list_date = models.CharField(max_length=20)

    def __str__(self):
        return self.name
    
    class Meta:
        db_table='stock_basic'
  
class StockInfo(models.Model):
    ts_code = models.CharField(max_length=10)
    trade_date = models.CharField(max_length=20)
    open = models.DecimalField(max_digits=10, decimal_places=2)
    high = models.DecimalField(max_digits=10, decimal_places=2)
    low = models.DecimalField(max_digits=10, decimal_places=2)
    close = models.DecimalField(max_digits=10, decimal_places=2)
    pre_close = models.DecimalField(max_digits=10, decimal_places=2)
    change = models.DecimalField(max_digits=10, decimal_places=2)
    pct_chg = models.DecimalField(max_digits=10, decimal_places=2)
    vol = models.BigIntegerField()
    amount = models.DecimalField(max_digits=15, decimal_places=2)
    
    
    class Meta:
        unique_together = ('ts_code', 'trade_date')